
import React from "react";


import {
  withRouter
} from "react-router-dom";
import { List } from 'antd';
import bossCss from './boss.module.css'

class History extends React.Component {
  state = {
    total:'',//总核销张数
    data:[{
      applyId: "",
      offStatus: "",
      offTime: "",
      voucherId: "",
      voucherNumber: ""
    }]

  }
  componentDidMount () {
    this.getUserInfo()
  }


  getUserInfo=()=>{
    const userId = this.props.location.state.userId
    this.$axios({
      method: 'post',
      url: `/wx/portal/queryMyOffList`,
      data:{
        userId
      }
    }).then(res =>{
      console.log(res,'核销数据')
       if(res.data.msg==="操作成功"){
        this.setState({
          data:res.data.data,
          total:res.data.data.length
        })   
       }

   }).catch(function (error) {
    console.log(error);
  })

  }

  render () {
    const { total,data }=this.state
    return (
      
      <div className={bossCss.history}>
        <div className={bossCss.totalTime}>
          <div style={{fontWeight:'bold'}}>总核销电子券:</div>
          <div style={{fontWeight:'bold'}}> {total}张</div>
        </div>
        <List
          itemLayout="horizontal"
          dataSource={data} 
          renderItem={item => (
            <List.Item>
              <List.Item.Meta                              
                title={ <div  >电子券ID:{item.voucherId}</div>}
                description={<div >
                  <div>申请编号:{item.applyId}</div>
                  <div  >电子券编号:{item.voucherNumber}</div>
                  <div  >核销日期:{item.offTime}</div>
                </div>
                }
              />
            </List.Item>
          )}
        />
      </div>

    );
  }
}



export default withRouter(History)

